import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { viteMockServe } from 'vite-plugin-mock'
import { fileURLToPath, URL } from "node:url";

// https://vite.dev/config/
export default defineConfig({
  server:{
    host:"0.0.0.0"
  },
  plugins: [
    react(),
    viteMockServe({
      mockPath: 'src/mock', // 模拟接口文件存放目录，默认/mock
      enable: true, // 开发环境启用
      // logger:true,
    }),
  ],
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
      "~": fileURLToPath(new URL("./src", import.meta.url)),
      "@components": fileURLToPath(
        new URL("./src/components", import.meta.url)
      ),
      "@pages": fileURLToPath(new URL("./src/pages", import.meta.url)),
      "@utils": fileURLToPath(new URL("./src/utils", import.meta.url)),
      "@styles": fileURLToPath(new URL("./src/styles", import.meta.url)),
      "@router": fileURLToPath(new URL("./src/router", import.meta.url)),
      "@api": fileURLToPath(new URL("./src/api", import.meta.url)),
      "@store": fileURLToPath(new URL("./src/store", import.meta.url)),
      "@hooks": fileURLToPath(new URL("./src/hooks", import.meta.url)),
    },
  },
})
